#include<bits/stdc++.h>
using namespace std;

struct aa
{
	int x, y;
	int data;
}box[10000005];

int main()
{
	int n, q;
	cin>>n>>q;
	int flag, i, j, ai;
	int cnt = 0;
	while(q--)
	{
		cin>>flag;
		if(flag == 1)
		{
			cin>>i>>j>>ai;
			box[cnt++] = {i, j, ai};
		}
		else
		{
			cin>>i>>j;
			for(int k = cnt-1;k >= 0;k--)
			{
				if(box[k].x == i && box[k].y == j)
				{
					cout<<box[k].data<<endl;
					break;
				}
			}
		}
	}
    return 0;
}

